﻿using RpcCentral.Model.DB;
using WeDonekRpc.Helper.IdGenerator;
using WeDonekRpc.SqlSugar;

namespace RpcCentral.DAL.Repository
{
    internal class ContainerDAL : IContainerDAL
    {
        private readonly IRepository<Contrainer> _Db;
        public ContainerDAL (IRepository<Contrainer> repository)
        {
            this._Db = repository;
        }

        public long Find (int groupId, string conId)
        {
            return this._Db.Get(c => c.GroupId == groupId && c.ContrainerId == conId, c => c.Id);
        }
        public long Reg (Contrainer add)
        {
            add.Id = IdentityHelper.CreateId();
            add.AddTime = DateTime.Now;
            this._Db.Insert(add);
            return add.Id;
        }
    }
}
